package tools;

import java.sql.Connection;
import java.sql.DriverManager;

import org.apache.commons.dbutils.QueryRunner;

public class DbTool {
	 
	 
	 public static Connection getConnection() { 
		 Connection conn = null;
		 try{  
	    	   Class.forName("com.mysql.jdbc.Driver");  
	            conn = DriverManager.getConnection(  
	                    "jdbc:mysql://210.16.189.39:3306/jee?useUnicode=true&characterEncoding=utf-8", "root","Ruoli1004");  
	       
	         }catch (Exception e) {  
	            e.printStackTrace();  
	        }  
	        return conn;  
	    }
	 public static boolean executeUpdate(Connection currentConn,String sql,Object[] parameter){ 
		  try {  
			  int result = new QueryRunner().update(currentConn, sql,parameter);  
		        if (result>0){
		        	return true;
		        }
		    } catch (Exception e) {  
		        e.printStackTrace();  
		    }
		 return false;
	 }
}
